package cn.tutu.blockchain.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;

import cn.tutu.blockchain.common.MsgObj;
import cn.tutu.blockchain.common.Page;
import cn.tutu.blockchain.transrecord.entity.TransRecord;
import cn.tutu.blockchain.transrecord.service.TransRecordService;

@RestController
@RequestMapping("/trans")
@Validated
public class TransRecordController {

	@Autowired
	private TransRecordService transRecordService;

	@RequestMapping("/create")
	public MsgObj create(@Valid TransRecord transRecord) {
		transRecordService.create(transRecord);
		return MsgObj.buildSuccessMsg();
	}

	@RequestMapping("/getGridByUser")
	public MsgObj getGrid(String userId, Page page) {

		PageInfo<TransRecord> byModel = transRecordService.getByUserId(userId, page);
		return MsgObj.buildSuccessObj(byModel.getList());

	}

}
